<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title></title>
     <link rel="stylesheet" type="text/css" href="${path}/css/main.css">
	<link rel="stylesheet" type="text/css" href="${path}/css/mainTable.css">
	<script type="text/javascript" language="javascript" src="${path}/js/calendar/js/WdatePicker.js"></script>
	<script type="text/javascript" language="javascript" src="${path}/js/jquery.js"></script>
	<script type="text/javascript" language="javascript" src="${path}/js/jquery.blockUI.js"></script>
	<script type="text/javascript">
		function check(){
			var mobile = document.getElementById("mobile").value;
			if(mobile != ''){
				if(mobile.length != 11){
					alert("请输入正确的手机号码!");
					return false;
				}
			}
			
			var time_begin = document.getElementById("time_begin").value;
			var time_end = document.getElementById("time_end").value;
			
			if(!isDate(time_begin)){
				alert("开始日期格式不对");
				return false;
			}
			if(!isDate(time_end)){
				alert("结束日期格式不对");
				return false;
			}
				
			var start = time_begin.replace(/\-/g,"/");
			var end = time_end.replace(/\-/g,"/");
				if(Date.parse(start) > Date.parse(end)){
				alert("结束日期不能小于开始日期!");
	    		return false;
			}
			$.blockUI({message: '正在查询...' });
		}
		
		function isDate(vDate){
			var regular = /^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/;
			var isMatch = vDate.match(regular);
			if(!isMatch){
				return false;
			}
			var date = new Date(isMatch[1],isMatch[3]-1,isMatch[4]);
			
			return (date.getFullYear()==isMatch[1]&&date.getMonth()==isMatch[3]-1&&date.getDate()==isMatch[4]);
		}
		
		function jump(i){
 			if(i == "" && document.getElementById("jump").value == ""){
				alert("请输入跳转页码!");
			}else if(parseInt(document.getElementById("jump").value) > parseInt(document.getElementById("totalPageNum").value)){
				alert("页码不能大于总页数!");
			}else{
				if(i == ""){
					document.getElementById("pageIndexs").value = document.getElementById("jump").value;
				}else{
					document.getElementById("pageIndexs").value = i;
				}
				document.forms["detailAnalysisPartnerForm"].submit();
			}
		}
	</script>
  </head>
  <body>
    <div>
    	<form id="detailAnalysisPartnerForm" name="detailAnalysisPartnerForm" method="post" action="${path }/analysisPartner/getDetailAnalysis.action" onsubmit="return check();">
    		<p>详细数据</p>
    		手<span style="font-family:'Times New Roman';">&nbsp;</span>机<span style="font-family:'Times New Roman';">&nbsp;</span>号<span style="font-family:'Times New Roman';">&nbsp;</span>码<span style="font-family:'Times New Roman';">&nbsp;</span>:
    		<input type="text" id="mobile" name="term.mobile" value="${term.mobile }" onkeyup="value=value.replace(/[^\d]/g,'')" />
    		<br />
    		业务长号码:
    		<select id="gateway_id" name="term.gateway_id">
    			<option value="0">全部</option>
    			<c:if test="${gatewayVoList != null && fn:length(gatewayVoList) > 0}">
    				<c:forEach var="gatewayVo" items="${gatewayVoList }" varStatus="list">
    					<option value="${gatewayVo.id }" <c:if test="${gatewayVo.id eq term.gateway_id }">selected</c:if>>${gatewayVo.sp_number }</option>
    				</c:forEach>
    			</c:if>
    		</select>
    		<br />
    		开<span style="font-family:'Times New Roman';">&nbsp;</span>始<span style="font-family:'Times New Roman';">&nbsp;</span>日<span style="font-family:'Times New Roman';">&nbsp;</span>期<span style="font-family:'Times New Roman';">&nbsp;</span>:
    		<input type="text" id="time_begin" name="term.time_begin" value="${term.time_begin }" class="Wdate" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false,readOnly:true})" size="10" maxlength="10" readonly="readonly" />
    		<br />
    		结<span style="font-family:'Times New Roman';">&nbsp;</span>束<span style="font-family:'Times New Roman';">&nbsp;</span>日<span style="font-family:'Times New Roman';">&nbsp;</span>期<span style="font-family:'Times New Roman';">&nbsp;</span>:
    		<input type="text" id="time_end" name="term.time_end" value="${term.time_end }" class="Wdate" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false,readOnly:true})" size="10" maxlength="10" readonly="readonly" />
    		<input type="submit" name="go" value="查询" />
    		
    		<table>
    			<thead>
    				<tr>
    					<th>手机号</th>
    					<th>业务长号码</th>
    					<th>开始时间</th>
    					<th>结束时间</th>
    					<th>计费时长(分)</th>
    					<th>计费时长(秒)</th>
    					<th>省份</th>
    					<th>城市</th>
    					<th>创建时间</th>
    					<th>同步状态</th>
    				</tr>
    			</thead>
    			<c:choose>
    				<c:when test="${userBillVoList != null && fn:length(userBillVoList) > 0}">
    					<c:forEach var="userBillVo" items="${userBillVoList }" varStatus="list">
    						<tr style="${list.index%2 != 0 ? 'background-color: #fea;' : 'background-color: #fff;' }">
    							<td>${userBillVo.mobile }</td>
    							<td>${userBillVo.sp_number }</td>
    							<td>${userBillVo.time_begin }</td>
    							<td>${userBillVo.time_end }</td>
    							<td>${userBillVo.minute }</td>
    							<td>${userBillVo.second }</td>
    							<td>${userBillVo.province }</td>
    							<td>${userBillVo.city }</td>
    							<td>${userBillVo.add_date }</td>
    							<td>
    								<c:if test="${userBillVo.dispatcher_status == 0 }">未同步</c:if>
    								<c:if test="${userBillVo.dispatcher_status != 0 }">${userBillVo.dispatcher_status }</c:if>
    							</td>
    						</tr>
    					</c:forEach>
    					
    					<input type="hidden" id="pageIndexs" name="pageIndexs" value=""/>
    					<c:if test="${pageInfo != null }">
    						<input type="hidden" id="totalPageNum" name="totalPageNum" value="${pageInfo.totalPageNum }"/>
    						查询到<font color=red> ${pageInfo.totalRowNum} </font>条记录,总共<font color=red> ${pageInfo.totalPageNum} </font>页,每页显示<font color=red>${pageInfo.pageSize }</font>条
    						当前第<font color=red> ${pageInfo.currentPageIndex} </font>页 
    						<c:choose>
    							<c:when test="${pageInfo.currentPageIndex==1 }">首页</c:when>
    							<c:otherwise>
    								<a href="javascript:jump('1')">首页</a>
    							</c:otherwise>
    						</c:choose>
    						<c:choose>
    							<c:when test="${pageInfo.currentPageIndex==1 }">上一页</c:when>
    							<c:otherwise>
    								<a href="javascript:jump('${pageIndexs - 1 }')">上一页</a>
    							</c:otherwise>
    						</c:choose>
    						<c:choose>
    							<c:when test="${pageInfo.currentPageIndex == pageInfo.totalPageNum }">下一页</c:when>
    							<c:otherwise>
    								<a href="javascript:jump('${pageIndexs + 1 }')">下一页</a>
    							</c:otherwise>
    						</c:choose>
    						<c:choose>
    							<c:when test="${pageInfo.currentPageIndex == pageInfo.totalPageNum }">尾页</c:when>
    							<c:otherwise>
    								<a href="javascript:jump('${pageInfo.totalPageNum}')">尾页</a>
    							</c:otherwise>
    						</c:choose>
    						
    						&nbsp;转到<input type=text name=jump id=jump size="3" onkeyup="value=value.replace(/[^\d]/g,'')" />
							<a href="javascript:jump('')" ><img border="0" src="${path }/image/go.gif" /></a>
    					</c:if>
    				</c:when>
    				<c:otherwise>
    					<tr>
    						<td>请输入查询条件!</td>
    					</tr>
    				</c:otherwise>
    			</c:choose>
    		</table>
    	</form>
    </div>
  </body>
</html>
